package cn.itcast.mq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * The type Common config.
 *
 * @author wwk
 */
@Configuration
public class CommonConfig {

    /**
     * Simple exchange direct exchange.
     *
     * @return the direct exchange
     */
    @Bean
    public DirectExchange simpleExchange(){
        // 三个参数：交换机名称、durable是否持久化、Autodelete:当没有queue与其绑定时是否自动删除
        return new DirectExchange("simple.direct", true, false);
    }

    /**
     * Simple queue queue.
     *
     * @return the queue
     */
    @Bean
    public Queue simpleQueue(){
        // 使用QueueBuilder构建队列，durable就是持久化的
        return QueueBuilder.durable("simple.queue")
                .build();
    }


}
